<?php
require_once "core/application/classes/checkClass.php";
/* Работа в админке */
if (!isset($_GET['control']) && !isset($_GET['what']) && !isset($_GET['add_ban']) && !isset($_GET['premiums']) && !isset($_GET['deletePremiumAccountFromDB']) && !isset($_GET['add_prem']) && !isset($_GET['edit_ban']) && !isset($_GET['del_ban']) && !isset($_GET['bans']) && !isset($_GET['settings']) && !isset($_GET['editSetting']) && !isset($_GET['bans'])) {
    require_once "core/application/views/adm_views/vadm.php";
}
require_once "core/application/views/adm_views/vadminheader.php";
//Если доступ разрешен - входим
if (isset($_SESSION['allow_adm']) && isset($_GET['adm'])) {



    if (isset($_GET['settings']) && isset($_GET['adm'])) {
        require_once "core/application/views/adm_views/vsettings.php";
        if (isset($_GET['action']) && $_GET['action'] == 'editSetting') {
            require_once "core/application/views/adm_views/veditedsettings.php";
        }
        if (isset($_GET['action']) && $_GET['action'] == 'show_settings') {
            require_once "core/application/views/adm_views/vshowsettings.php";
        }
        if (isset($_GET['action']) && $_GET['action'] == 'gameshop') {
            require_once "core/application/views/adm_views/vgmshop.php";
        }
        if (isset($_POST['save'])) {
            require_once "core/application/controllers/csettings.php";
            settings_Controller::getInstance()->save_settings();
        }
        
        if (isset($_POST['addNewItem'])) {
            require_once "core/application/controllers/cgmshop.php";
            GMShop_Controller::getInstance()->insertNewItem();
        }
        if (isset($_GET['subaction']) && $_GET['subaction'] == 'gmshop_delete_item') {
            require_once "core/application/controllers/cgmshop.php";
            GMShop_Controller::getInstance()->deleteItem();
        }
    }
    if (isset($_GET['control'])) {
        if (!isset($_GET['what']))
            require_once "core/application/views/adm_views/vcontrol.php";
        /**
         * б а н ы
         */
        if (isset($_GET['what']) && $_GET['what'] == 'bans') {
            require_once "core/application/views/adm_views/vbans.php";
        }

        if (isset($_GET['what']) && $_GET['what'] == 'newBan') {
            require_once "core/application/views/adm_views/vaddban.php";
        }
        if (isset($_GET['what']) && $_GET['what'] == 'deleteBan') {
            require_once "core/application/controllers/cbans.php";
            bans_Controller::getInstance()->delban();
        }
        if (isset($_GET['what']) && $_GET['what'] == 'editBan') {
            require_once "core/application/views/adm_views/veditban.php";
        }
        if (isset($_POST['ban'])) {
            require_once "core/application/controllers/cbans.php";
            bans_Controller::getInstance()->addban();
        }
        if (isset($_POST['edit_ban'])) {
            require_once "core/application/controllers/cbans.php";
            bans_Controller::getInstance()->editban_save();
        }
        if (isset($_GET['del_all_bans'])) {
            require_once "core/application/controllers/cbans.php";
            bans_Controller::getInstance()->delallbans();
        }
        /**
         * к о н е ц   б а н ов 
         */
        /**
         * п р е м и у м ы
         */
        if (isset($_GET['what']) && $_GET['what'] == 'premiums') {
            require_once "core/application/views/adm_views/vpremiums.php";
        }

        if (isset($_GET['what']) && $_GET['what'] == 'addPremium') {
            require_once "core/application/views/adm_views/vaprem.php";
        }
        if (isset($_GET['what']) && $_GET['what'] == 'deletePremium') {
            require_once "core/application/controllers/cpremiums.php";
            PremiumAccounts_Controller::getInstance()->delPremiumFromList();
        }
        if (isset($_POST['add_prem'])) {
            require_once "core/application/controllers/cpremiums.php";
            PremiumAccounts_Controller::getInstance()->addPremiumToList();
        }

        /**
         * к о н е ц   п р е м и у м о в
         */
    }
} else {
    error::getInstance('Такая страница не была найдена');
}
?>
